package com.wc.acwing.基础算法.数学知识.约数.Q4662_因数平方和;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/23 11:35
 * @description https://www.acwing.com/problem/content/4665/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int n;
    static int P = (int) 1e9 + 7;

    /**
     * 整数分块 + 逆元 + 平方和公式
     * 10
     * 1 2 3 4 5 6 7 8 9 10
     * 10 5 3 2 2 1 1 1 1 1
     * 10 * 1 ^ 2 + 5 (2 ^ 2) + 3 * (3 ^ 2) + 2*(4^2 + 5^2) + 1 * (6^2 + 7^2 + 8^2 + 9^2 + 10^2)
     */
    public static void main(String[] args) {
        n = sc.nextInt();
        long res = 0;
        // 求6与P的逆元计算出166666668
//        System.out.println(qkm(6, P - 2, P));
        int d = 1;
        while (n / d > 0) {
            // x 个长度
            int x = n / d;
            // y 表示最大的d 能使得 n / y = d
            int y = n / x;
            res = (res + x * (ff(y) - ff(d - 1)) + P) % P;
            d = y;
            d++;
        }
        out.println((res + P) % P);
        out.flush();
    }

    // 平方和公式
    static long ff(long n) {
        return n * (n + 1) % P * (2 * n + 1) % P * 166666668 % P;
    }

    static long qkm(long a, long b, int p) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) res = res * a % P;
            b >>= 1;
            a = a * a % p;
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
